package com.ocelot.san.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.ocelot.san.dto.User;
import com.ocelot.san.repository.UserRepository;

@Service
public class UserService {
	
	@Resource
	private UserRepository userRepository;
	
	public void save(User user) {
		userRepository.save(user);
	}
	
	public User findById(String id) {
		return userRepository.findOne(id);
	}

	public void delete(String id) {
		userRepository.delete(id);
	}
	
	public List<User> fetchAll() {
		return userRepository.findAll(new Sort(Sort.Direction.ASC, "name"));
	}

}
